<template>
  <page-body>
    <view class="page">
      <view class="flex flex-direction align-stretch justify-between benben-position-layout flex search_flex_0"
        :style="{height:(93+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between search_fd0_0'>
          <text class='fu-iconfont2  search_fd0_0_c0' @tap.stop="handleJumpDiy"  data-type="back"
               data-url="1">&#xE794;</text>
          <view class='flex flex-wrap align-center flex-sub search_fd0_0_c1'>
            <benben-input class='flex-sub search_fd0_0_c1_c0' type="text" :placeholder="`请输入关键字`" confirm-type="done"
              :maxlength="-1" placeholder-style="color:#999;font-size:24rpx" @confirm="navSearchFunc()"
              v-model="KeyWord" />
          </view>
          <image class='search_fd0_0_c2' mode="aspectFit" :src='STATIC_URL+"guofang/64.png"' @tap.stop="navSearchFunc()">
          </image>
        </view>

      </view>
      <view :style="{height: (93+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout search_flex_1">
        <view class='flex flex-wrap align-center search_fd1_0'>
          <image class='search_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"guofang/65.png"'></image>
          <text class='search_fd1_0_c1'>历史搜索</text>
          <text class='fu-iconfont2  search_fd1_0_c2' @tap.stop="popupShow1724835603384=true">&#xe754;</text>
        </view>
        <view class='flex flex-wrap align-center'>
          <template v-for='(item,key0) in list'>
            <view class='flex flex-wrap align-center search_fd1_1_c0' :key='key0'>
              <text class='search_fd1_1_c0_c0' @tap.stop="ClickHistory(item)">{{item}}</text>
              <text class='fu-iconfont2  search_fd1_1_c0_c1' @tap.stop="removeDanFunc(key0)">&#xe695;</text>
            </view>
          </template>

        </view>
      </view>

      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1724835603384" :mask="true" :mask-close-able="true" mode='center'
        :z-index='999999'>
        <!---flex布局flex布局开始-->
        <view class="flex benben-flex-layout flex-wrap align-center">
          <view class='flex flex-direction flex-wrap align-stretch justify-between search_fd2_0'>
            <view class='flex flex-direction flex-wrap align-center justify-around search_fd2_0_c0'>
              <text class='search_fd2_0_c0_c0'>提示</text>
              <text class='search_fd2_0_c0_c1'>确定清空历史搜索吗？</text>
            </view>
            <view class='flex flex-wrap align-center justify-center search_fd2_0_c1'>
              <view class='flex flex-wrap align-center justify-center search_fd2_0_c1_c0' @tap.stop="popupShow1724835603384=false">
                <text class='search_fd2_0_c1_c0_c0'>取消</text>
              </view>
              <view class='flex flex-wrap align-center justify-center search_fd2_0_c1_c1' @tap.stop="qingkongFunc()">
                <text class='search_fd2_0_c1_c1_c0'>确定</text>
              </view>
            </view>
          </view>
        </view>

        <!---flex布局flex布局结束-->

      </benben-popup>


    </view>
  </page-body>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "popupShow1724835603384": false,
        "KeyWord": "",
        "list": [],
        type:null,
        are:""
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      let {type} = options
      if(type!=undefined) this.type= type
      // if(are!=undefined) this.are= are

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getStorageSyncFunc()
      this.are=uni.getStorageSync("are")
    },
    onHide() {
    this.KeyWord = ""
    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      /* 点击历史搜索*/
      ClickHistory(item){
        item = item.replace(/\s+/g, '');
        if(item!=""){
          this.KeyWord=item
          this.navSearchFunc()
        }else{
          this.$message.info("搜索内容不能为空")
        }
      },
      //跳转页面
      navSearchFunc() {
        console.log(typeof this.list)
        this.KeyWord = this.KeyWord.replace(/\s+/g, '');
        if(this.KeyWord==""){
          this.$message.info("搜索内容不能为空")
          return
        }
        let arr = [...this.list]
        arr.push(this.KeyWord)
         let arrs = [...new Set(arr)]
        uni.setStorageSync("list", arrs);
        if(this.are==4&&!this.type){
          this.$urouter.navigateTo(`/pages/index/searchRow/searchRow?keyword=${this.KeyWord}`);
        }
        if(this.are==5&&!this.type){
          this.$urouter.navigateTo(`/pageguofang/help/RowHoS4/RowHoS4?keyword=${this.KeyWord}`);
        }
        if(this.type){
            this.$urouter.navigateTo(`/pages/index/joinsearchNav/joinsearchNav?keyword=${this.KeyWord}`);
        }
        if(this.are==1&&!this.type){
          this.$urouter.navigateTo(`/pages/help/RowHoS1/RowHoS1?keyword=${this.KeyWord}`);
        }
        if(this.are==2&&!this.type){
          this.$urouter.navigateTo(`/pageguofang/help/RowHoS12/RowHoS12?keyword=${this.KeyWord}`);
        }
        if(this.are==3&&!this.type){
          this.$urouter.navigateTo(`/pageguofang/help/RowHoS3/RowHoS3?keyword=${this.KeyWord}`);
        }
        if(!this.are&&!this.type){
          this.$urouter.navigateTo(`/pages/index/searchRow/searchRow?keyword=${this.KeyWord}`);
        }

      },
      //清空搜索历史
      qingkongFunc() {
        this.list = []
        uni.setStorageSync("list", this.list);

        this.popupShow1724835603384 = false;
      },
      //获取本地缓存
      getStorageSyncFunc() {
        if (uni.getStorageSync("list")) {
          let arr = uni.getStorageSync("list")
          this.list = [...new Set(arr)]  ;

        } else {
          this.list = []
        }
        console.log("this.list=>", this.list)
      },
      //删除单个记录
      removeDanFunc(ind) {
        this.list.splice(ind, 1);

        uni.setStorageSync("list", this.list);
        console.log(uni.getStorageSync("list"))
        this.$forceUpdate()
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .search_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 93rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: #eee;
  }

  .search_fd0_0_c2 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 40rpx;
  }

  .search_fd0_0_c1_c0 {
    font-size: 24rpx;
    font-weight: 400;
    color: #333;
  }

  .search_fd0_0_c1 {
    background: rgba(249, 249, 249, 1);
    height: 64rpx;
    background-size: 100% auto !important;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
  }

  .search_fd0_0_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
    margin: 0rpx 34rpx 0rpx 0rpx;
  }

  .search_fd0_0 {
    padding: 0rpx 24rpx 0rpx 35rpx;
    line-height: 93rpx;
  }

  .search_flex_1 {
    padding: 32rpx 24rpx 32rpx 24rpx;
  }

  .search_fd1_1_c0_c1 {
    color: rgba(153, 153, 153, 1);
    font-size: 16rpx;
    margin: 0rpx 0rpx 0rpx 16rpx;
  }

  .search_fd1_1_c0_c0 {
    font-size: 24rpx;
    line-height: 28rpx;
  }

  .search_fd1_1_c0 {
    background: #Fff;
    padding: 12rpx 21rpx 12rpx 21rpx;
    border-radius: 32rpx;
    height: 56rpx;
    background-size: 100% auto;
    margin: 24rpx 12rpx 0rpx 12rpx;
  }

  .search_fd1_0_c2 {
    position: absolute;
    right: 0rpx;
    top: 0rpx;
  }

  .search_fd1_0_c1 {
    font-size: 32rpx;
    line-height: 38rpx;
    margin: 0rpx 0rpx 0rpx 16rpx;
    font-weight: 500;
  }

  .search_fd1_0_c0 {
    width: 34rpx;
    height: 34rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd1_0 {
    position: relative;
  }

  .search_fd2_0_c1_c1_c0 {
    color: rgba(51, 51, 51, 1);
    font-size: 32rpx;
    line-height: 45rpx;
    font-weight: 500;
  }

  .search_fd2_0_c1_c1 {
    width: 259rpx;
    height: 98rpx;
  }

  .search_fd2_0_c1_c0_c0 {
    font-size: 32rpx;
    line-height: 44rpx;
    color: rgba(153, 153, 153, 1);
  }

  .search_fd2_0_c1_c0 {
    border-right: 1px solid #eee;
    width: 259rpx;
    height: 98rpx;
  }

  .search_fd2_0_c1 {
    height: 99rpx;
  }

  .search_fd2_0_c0_c1 {
    margin: 0rpx 0rpx 030rpx 0rpx;
    font-size: 36rpx;
    color: #333;
    line-height: 50rpx;
    font-weight: 500;
  }

  .search_fd2_0_c0_c0 {
    font-size: 32rpx;
    line-height: 44rpx;
    color: rgba(153, 153, 153, 1);
    font-weight: 800;
  }

  .search_fd2_0_c0 {
    border-bottom: 1px solid #eee;
    height: 227rpx;
  }

  .search_fd2_0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 25rpx;
    width: 540rpx;
    height: 332rpx;
    background-size: 100% auto;
  }
</style>
